﻿using W.Models.DataAccess;
using System.Collections.Generic;
using System.Data;
using System;
using System.Reflection;
using System.Linq;
using System.Data.Objects;
using System.Data.Linq;
using W.Models.Utils;

namespace W.Component
{
    public class UsuariosComponent : ComponentBase<Usuarios>
    {
        public Usuarios get(string username, string password)
        {
            Usuarios Usuario = this.Model.Usuarios.SingleOrDefault(t => t.username == username && t.password == password);
            Usuario.lastActivityDay = DateTime.Now;
            this.Model.SaveChanges();

            return Usuario;
        }

        public bool LoginSuccess(string username, string password)
        {
            return this.Model.Usuarios.ToList().Exists(t => t.username == username && t.password == password);
        }
    }
}
